package com.project.bean;

import com.project.util.ValidateAdd;
import com.project.util.ValidateUpdate;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.*;

public class UserBean {
    private int id;
    //非空验证
    @NotBlank(groups = ValidateAdd.class,message = "姓名不能为空")
    private String name;
    //字符串长度验证
    @Length(groups = ValidateUpdate.class,min = 6,max = 6,message = "密码只能为6位字符")
    private String pwd = "666666";
    //正则表达式验证
    @Pattern(groups ={ValidateAdd.class,ValidateUpdate.class} ,
            regexp = "1[3578]\\d{9}",
            message = "电话只能是13、15、17、18开始的11位数")
    private String phone;
    //数字范围验证
    @Min(groups ={ValidateAdd.class,ValidateUpdate.class} ,
            value = 1800,message = "这么低的工资，不让人活了")
    @Max(groups ={ValidateAdd.class,ValidateUpdate.class} ,
            value = 10000,message = "工资这么高，老板扔钱也不是这么扔的")
    private Integer money;
    //邮箱验证
    @Email(groups = ValidateAdd.class,message = "邮箱格式为XXX@XX.com")
    private String email;

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPwd() {
        return pwd;
    }

    public void setPwd(String pwd) {
        this.pwd = pwd;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public Integer getMoney() {
        return money;
    }

    public void setMoney(Integer money) {
        this.money = money;
    }

    @Override
    public String toString() {
        return "UserBean{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", pwd='" + pwd + '\'' +
                ", phone='" + phone + '\'' +
                ", money=" + money +
                ", email='" + email + '\'' +
                '}';
    }
}
